// class MyRouter {
//   constructor() {
//     this.routes = []
//   }
// }
import { h } from 'vue'
const routes = [
  {
    path: '/',
    component: () => h('div', {}, 'home')
  },
  {
    path: '/input',
    component: () => import('@/components/input.vue')
  },
  {
    path: '/button',
    component: () => import('@/components/button.vue')
  },
  {
    path: '/radio',
    component: () => import('@/components/radio.vue')
  }
]



window.addEventListener("hashchange", (event) => {
  // console.log(event)
  const {oldURL, newURL} = event
  const newPath = newURL.split('#/')[1]
  window.history.pushState({}, '', newPath)
});



class MyRouter {
  install(app: Record<string, any>) {
    console.log(app)
    app.component('router-view', {
      render() {
        // return h('div', {}, this.$slots.default?.())
        return h('div', {}, 123)
      }
    })
    // app.config.globalProperties.$router = this
  }

  push(path: string) {
    window.location.hash = '#' + path
  }
}

const router = new MyRouter()
export function createRouter() {
  return router
}
